{% set pypi_name = 'ironic-lib' %}
{% set upstream_version = upstream_version('4.4.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}

Name:           {{ py2name(py_versions='py3') }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        Ironic Common Libraries
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/ironic-lib/latest/
Source0:        https://files.pythonhosted.org/packages/source/i/ironic-lib/ironic-lib-%{version}.tar.gz
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('bcrypt') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslo.concurrency') }}
BuildRequires:  {{ py3('oslo.log') }}
BuildRequires:  {{ py3('oslo.service') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('pbr') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('tenacity') }}
BuildRequires:  {{ py3('zeroconf') }}
Requires:       {{ py3('bcrypt') }}
Requires:       {{ py3('eventlet') }}
Requires:       {{ py3('oslo.concurrency') }}
Requires:       {{ py3('oslo.config') }}
Requires:       {{ py3('oslo.i18n') }}
Requires:       {{ py3('oslo.log') }}
Requires:       {{ py3('oslo.serialization') }}
Requires:       {{ py3('oslo.service') }}
Requires:       {{ py3('oslo.utils') }}
Requires:       {{ py3('requests') }}
Requires:       {{ py3('tenacity') }}
Requires:       {{ py3('zeroconf') }}
BuildArch:      noarch

%description
A common library to be used **exclusively** by projects under the `Ironic
governance <https://governance.openstack.org/tc/reference/projects/ironic.html>`

%prep
%autosetup -p1 -n {{ pypi_name }}-{{ upstream_version }}
%py_req_cleanup

%build
%{py3_build}

%check
python3 -m stestr.cli run

%install
%{py3_install}

install -p -m 755 -d %{buildroot}/%{_sysconfdir}/ironic/rootwrap.d
install -p -m 640 etc/ironic/rootwrap.d/*.filters %{buildroot}/%{_sysconfdir}/ironic/rootwrap.d/
rm -rf %{buildroot}/%{_prefix}/%{_sysconfdir}/ironic/rootwrap.d

%files
%license LICENSE
%doc ChangeLog README.rst
%{python3_sitelib}/ironic_lib
%{python3_sitelib}/ironic_lib*egg-info
%dir %{_sysconfdir}/ironic
%dir %{_sysconfdir}/ironic/rootwrap.d
%{_sysconfdir}/ironic/rootwrap.d/*.filters

%changelog
